package com.shenyue.nbtownlet.model;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;
import com.shenyue.nbtownlet.event.BaseListener;

/**
 * 每月考勤
 */
public class AppMonthlyModel {

    //获取每月考核列表
    public static final String GETMONTHLYASSESSMENTQUERY = "SmallTown/MonthlyAssessment/GetMonthlyAssessmentQuery";
    public static final String GETMONTHLYASSESSMENTQUERY_ACTION = "$smalltown_monthlyassessment_getmonthlyassessmentquery_action$";

    //获取任务详情接口
    public static final String GETASSESSMENT = "SmallTown/MonthlyAssessment/GetAssessMent";
    public static final String GETASSESSMENT_ACTION = "$smalltown_monthlyassessment_getassessment_action$";

    //用主表ID获取每月考核子表内容集合
    public static final String GETCONTENTSBYMAINID = "SmallTown/MonthlyAssessment/GetContentsByMainId";
    public static final String GETCONTENTSBYMAINID_ACTION = "$smalltown_monthlyassessment_getcontentsbymainid_action$";

    //用子表ID获取每月考核子表内容单条
    public static final String GETCONTENTBYID = "SmallTown/MonthlyAssessment/GetContentById";
    public static final String GETCONTENTBYID_ACTION = "$smalltown_monthlyassessment_getcontentbyid_action$";

    //用主表ID获取主表内容
    public static final String GETASSESSINFO = "SmallTown/MonthlyAssessment/GetAssessInfo";
    public static final String GETASSESSINFO_ACTION = "$smalltown_monthlyassessment_getassessinfo_action$";

    //子列表内容新增接口
    public static final String ADDMONTHLYASSESSMENT = "SmallTown/MonthlyAssessment/AddMonthlyAssessment";
    public static final String ADDMONTHLYASSESSMENT_ACTION = "$smalltown_monthlyassessment_addmonthlyassessment_action$";

    //主表信息存在情况下新增及修改子表信息的接口
    public static final String ADDMONTHLYASSESSMENTCONTENT = "SmallTown/MonthlyAssessment/AddMonthlyAssessmentContent";
    public static final String ADDMONTHLYASSESSMENTCONTENT_ACTION = "$smalltown_monthlyassessment_addmonthlyassessmentcontent_action$";

    //修改主表内容
    public static final String SAVEMAIN = "SmallTown/MonthlyAssessment/SaveMain";
    public static final String SAVEMAIN_ACTION = "$smalltown_monthlyassessment_savemain_action$";

    //删除子表内容
    public static final String DELETECONTENT = "SmallTown/MonthlyAssessment/DeleteContent";
    public static final String DELETECONTENT_ACTION = "$smalltown_monthlyassessment_deletecontent_action$";


    /**
     * 获取每月考核列表
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void GetMonthlyAssessmentQuery(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + GETMONTHLYASSESSMENTQUERY, GETMONTHLYASSESSMENTQUERY_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 获取任务详情接口
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void GetAssessMent(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + GETASSESSMENT, GETASSESSMENT_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 用主表ID获取每月考核子表内容集合
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void GetContentsByMainId(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + GETCONTENTSBYMAINID, GETCONTENTSBYMAINID_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 用子表ID获取每月考核子表内容单条
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void GetContentById(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + GETCONTENTBYID, GETCONTENTBYID_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 用主表ID获取主表内容
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void GetAssessInfo(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().get(AppModel.kBaseURL + "/" + GETASSESSINFO, GETASSESSINFO_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 删除子表内容
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void DeleteContent(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().post(AppModel.kBaseURL + "/" + DELETECONTENT, DELETECONTENT_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 修改主表内容
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void SaveMain(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().post(AppModel.kBaseURL + "/" + SAVEMAIN, SAVEMAIN_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 主表信息存在情况下新增及修改子表信息的接口
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void AddMonthlyAssessmentContent(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().post(AppModel.kBaseURL + "/" + ADDMONTHLYASSESSMENTCONTENT, ADDMONTHLYASSESSMENTCONTENT_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }

    /**
     * 子列表内容新增接口
     *
     * @param context
     * @param param
     * @param listener
     */
    public static void AddMonthlyAssessment(final Context context, JSONObject param, final BaseListener listener) {
        HttpClientExManager.instance().post(AppModel.kBaseURL + "/" + ADDMONTHLYASSESSMENT, ADDMONTHLYASSESSMENT_ACTION, param, new BaseListener() {
            @Override
            public void success(String val, String action) {
                if (listener != null)
                    listener.success(val, action);
            }

            @Override
            public void error(String error, String action) {
                if (listener != null)
                    listener.error(error, action);
            }
        });
    }
}
